package org.marsdonne.monitring_agent.activemq

import org.springframework.boot.context.properties.ConfigurationProperties

@ConfigurationProperties("restarter")
class Restarter {

    String command

    String process() {
        def result = new StringBuilder("[执行重启命令]")
        def proc = command.execute()

        switch (proc.waitFor()) {
            case 0:
                result.append("执行成功: $proc.in.text")
                break
            default:
                result.append("执行失败，返回码[${proc.exitValue()}],错误提示:$proc.err.text")
                break
        }

        return result.toString()
    }
}
